package com.whf.android.jar.util.skip;

import android.annotation.SuppressLint;
import android.view.View;

import com.whf.android.jar.R;
import com.whf.android.jar.app.Latte;
import com.whf.android.jar.popup.LattePopupBottom;

import java.util.List;

/**
 * 导航软件选择弹框
 *
 * @author qf
 * @version 1.0.2
 */
@SuppressLint("ViewConstructor")
public class SkipPopup extends LattePopupBottom implements View.OnClickListener {

    private final List<String> check;
    private final IClickListener iClickListener;

    public SkipPopup(List<String> check, IClickListener listener) {
        super(Latte.getActivity());
        this.check = check;
        this.iClickListener = listener;
    }

    @Override
    protected int setLayout() {
        return R.layout.hai_popup_skip;
    }

    @Override
    protected void initViews() {
        setOnClickListener(R.id.button_bai_du, this);
        setOnClickListener(R.id.button_gao_de, this);
        setOnClickListener(R.id.button_tencent, this);
        setOnClickListener(R.id.button_cancel, this);
        setShow(R.id.button_bai_du, check.contains("百度地图"));
        setShow(R.id.view_bai_du, check.contains("百度地图"));
        setShow(R.id.button_gao_de, check.contains("高德地图"));
        setShow(R.id.view_gao_de, check.contains("高德地图"));
        setShow(R.id.button_tencent, check.contains("腾讯地图"));
        setShow(R.id.view_tencent, check.contains("腾讯地图"));
    }

    @Override
    public void onClick(View v) {
        dismiss();
        if (v == null) {
            return;
        }
        int id = v.getId();
        if (id == R.id.button_bai_du) {
            if (iClickListener != null) {
                iClickListener.daiDu();
            }
        } else if (id == R.id.button_gao_de) {
            if (iClickListener != null) {
                iClickListener.gaoDe();
            }
        } else if (id == R.id.button_tencent) {

            if (iClickListener != null) {
                iClickListener.tencent();
            }
        }
    }

    /*** 开始导航 */
    interface IClickListener {
        /*** 打开百度地图开始导航 */
        void daiDu();

        /*** 打开高德地图开始导航 */
        void gaoDe();

        /*** 打开腾讯地图开始导航 */
        void tencent();
    }
}
